$( document ).on( "pageshow", "#myEndPlate", function( event ) {
		access_token=getQueryString("access_token");

		pageNo="1";
		pageSize="10";
		$("#wrapper_myEndPlate  #pullDown").hide();
		
		//加载用户信息
		loadUserInfo();
		
		var scrollObj_myEndPlate=scrollPlugLoadedOfReturn("wrapper_myEndPlate",
					function() {
						setTimeout(function () {
							if(pageNo >= totalPage)
								return;
							pageNo++;
							loadData_myEndPlate(false,scrollObj_myEndPlate);
						}, 1000);	
					},
					function() {
//						setTimeout(function () {
//							pageNo=1;
//							loadData_myEndPlate(true);
//						}, 1000);
						scrollObj_myEndPlate.refresh();
					});
			
		loadData_myEndPlate(true,scrollObj_myEndPlate);
			
		//去吐槽
		$("#to_tuCao").on("click",function (){
			goTo(rootPath+"/jsp/weixin/endPlate.jsp?access_token="+access_token);
		});
		
});
$( document ).on( "pagecreate", "#myEndPlate", function( event ) {
		
});


function loadUserInfo(){
	$.ajax({
	  	url: rootPath+"/user/personInfo.do",
	  	type: "POST",
	  	dataType: "text",
		data: "access_token="+access_token,
	  	success: function( response ) {
	  		var data=$.parseJSON(response);
	  		
			if(data.state=="200"){
				totalPage=data.data.totalPage;
		  		var user=data.data;
		  		$("#userName_myEndPlate").text(user.empName);
		  		var ctNum=user.canTuCaoNum==null || user.canTuCaoNum=="" ? 0 :user.canTuCaoNum;
		  		if(ctNum==-1){
		  			$("#showTuCaoNumInfo").empty();
		  			$("#showTuCaoNumInfo").text("吐槽机会不受限制");
		  		}else if(ctNum==0){
		  			$("#canTuCaoNum").text(ctNum);
		  			$("#to_tuCao").hide();
		  			$("#showTuCaoNumInfo").hide();
		  		}else{
		  			$("#canTuCaoNum").text(ctNum);
		  			$("#to_tuCao").on("click",function(){
		  				goTo(rootPath+"/jsp/weixin/endPlate.jsp?access_token="+access_token);
		  			});
		  		}
		  		
		  		var userHeadPic=user.headImageUrl==undefined||user.headImageUrl==null? rootPath+defaultHeadPic :user.headImageUrl;
		  		$("#userHead_myEndPlate").attr("src",userHeadPic).show();
			}else{
				alert_wx('fail',data.msg);
			}
	  	}
	});
}
/**
 * 
 * @param isFresh 是否刷新
 * @param isFresh 是否初始列表
 */
function loadData_myEndPlate(isFresh,scrollObj_myEndPlate){
	$.ajax({
	  	url: rootPath+"/user/myEndPlate.do",
	  	type: "POST",
	  	dataType: "text",
		data: "access_token="+access_token+"&pageNo="+pageNo+"&pageSize="+pageSize,
	  	success: function( response ) {
	  		var data=$.parseJSON(response);
			if(data.state=="200"){
				var totalPage=data.data.totalPage;
		  		var totalRow=data.data.totalRow;
		  		var arr=data.data.rows;
				var content = "";
				for (var i=0;i<arr.length;i++){
					var toPage=rootPath+"/jsp/weixin/endPlateInfo.jsp?toEndPlateId="+arr[i].id+"&access_token="+access_token;//去吐槽详情页
					var headerPic=rootPath+defaultHeadPic;
					if(arr[i].headImageUrl!=undefined && arr[i].headImageUrl!="")
						headerPic=arr[i].headImageUrl;
						content +='<li>\
							  <a href="#" onClick="goTo(\''+toPage+'\')" '+comStyle+' >\
								<img '+imgStyle+' src="'+headerPic+'" class="ui-li-icon">\
								<p '+margin_top_no+' ><span style="font-size:15px;">'+arr[i].emp_name+'</span><strong class="ui-li-aside_fresh" '+sideStyle+' style="right: 35px;">'+arr[i].create_timeStr+'</strong></p>\
								<p '+margin_top_6+'>'+replaceContent(arr[i].endPlateCon)+'</p>\
							  </a>\
							</li>';
				}
				if(arr.length<pageSize){
					$("#wrapper_myEndPlate  #pullUp").hide();
				}else{
					$("#wrapper_myEndPlate  #pullUp").show();
				}
				if(isFresh)
					$("#thelist_myEndPlate").html("");
					
				$("#thelist_myEndPlate").append(content).listview('refresh');
				
				scrollObj_myEndPlate.refresh();
				
			}else{
				alert_wx('fail',data.msg);
			}
	  	}
	});
}



				